namespace WinnerCMS.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class NewDataBase : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.CMS_Adverts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SiteName = c.String(maxLength: 50),
                        UserName = c.String(maxLength: 50),
                        Contact = c.String(maxLength: 200),
                        AdUrl = c.String(maxLength: 300),
                        Url = c.String(maxLength: 50),
                        Width = c.Int(nullable: false),
                        Height = c.Int(nullable: false),
                        Target = c.String(maxLength: 50),
                        MaxShowTime = c.Int(nullable: false),
                        MaxClick = c.Int(nullable: false),
                        MaxDateTime = c.DateTime(nullable: false),
                        Show = c.Int(),
                        Clicks = c.Int(),
                        UpDateTime = c.DateTime(nullable: false),
                        ShowType = c.Int(),
                        Remark = c.String(maxLength: 1000),
                        IsStop = c.Boolean(nullable: false),
                        Note = c.String(maxLength: 200),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Annexes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ContentId = c.Int(),
                        FileName = c.String(maxLength: 100),
                        DownURL = c.String(maxLength: 255),
                        UpDateTime = c.DateTime(),
                        TempFlag = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.ContentId);
            
            CreateTable(
                "dbo.CMS_Announces",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Byte(nullable: false),
                        Title = c.String(nullable: false, maxLength: 100),
                        Author = c.String(nullable: false, maxLength: 50),
                        Content = c.String(nullable: false),
                        Pass = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        UpdateTime = c.DateTime(nullable: false),
                        EffectivDate = c.DateTime(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Areas",
                c => new
                    {
                        Code = c.String(nullable: false, maxLength: 50),
                        Name = c.String(nullable: false, maxLength: 50),
                        Path = c.String(maxLength: 250),
                        FullName = c.String(maxLength: 250),
                        Abbreviation = c.String(maxLength: 50),
                        Level = c.Int(),
                        ParentCode = c.String(maxLength: 50),
                        DeliveryArea_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Code)
                .ForeignKey("dbo.CMS_DeliveryAreas", t => t.DeliveryArea_Id)
                .Index(t => t.DeliveryArea_Id);
            
            CreateTable(
                "dbo.CMS_Cores",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CategoryId = c.Int(nullable: false),
                        ContentTitle = c.String(nullable: false, maxLength: 100),
                        Brief = c.String(nullable: false, maxLength: 255),
                        CssClass = c.String(maxLength: 50, unicode: false),
                        Editor = c.String(nullable: false, maxLength: 50),
                        Hits = c.Int(nullable: false),
                        DayHits = c.Int(nullable: false),
                        WeekHits = c.Int(nullable: false),
                        MonthHits = c.Int(nullable: false),
                        IncludePic = c.Boolean(nullable: false),
                        PicUrl = c.String(nullable: false, maxLength: 255, unicode: false),
                        Stars = c.Byte(nullable: false),
                        IsSlide = c.Boolean(nullable: false),
                        IsHeadline = c.Boolean(nullable: false),
                        IsElite = c.Boolean(nullable: false),
                        IsOnTop = c.Boolean(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        IsChecked = c.Boolean(nullable: false),
                        IsDraft = c.Boolean(nullable: false),
                        Rank = c.Short(nullable: false),
                        PointNum = c.Short(nullable: false),
                        AllowComment = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        UpdateTime = c.DateTime(nullable: false),
                        LastHitTime = c.DateTime(),
                        TemplateFileName = c.String(nullable: false, maxLength: 255, unicode: false),
                        CommentQuantity = c.Int(nullable: false),
                        CommentScore = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Categories", t => t.CategoryId)
                .Index(t => t.CategoryId)
                .Index(t => t.ContentTitle);
            
            CreateTable(
                "dbo.CMS_Categories",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Byte(nullable: false),
                        CategoryName = c.String(maxLength: 50),
                        CategoryNameEN = c.String(maxLength: 50, unicode: false),
                        ParentId = c.Int(),
                        OrderId = c.Int(nullable: false),
                        LinkUrl = c.String(maxLength: 300),
                        Path = c.String(maxLength: 50),
                        DomainName = c.String(maxLength: 255),
                        FilePostfix = c.String(maxLength: 10),
                        FilePrefix = c.String(maxLength: 10),
                        UrlStyle = c.Int(nullable: false),
                        CategoryFilePostfix = c.String(maxLength: 10),
                        CategoryFilePrefix = c.String(maxLength: 10),
                        CategoryUrlStyle = c.Int(nullable: false),
                        CategoryIntro = c.String(maxLength: 255),
                        CategoryPic = c.String(maxLength: 255),
                        CategoryDescription = c.String(maxLength: 500),
                        CategoryKeyWord = c.String(maxLength: 500),
                        EnableContribute = c.Boolean(),
                        EnableComment = c.Boolean(),
                        TemplateFileName = c.String(maxLength: 255),
                        ShowPageTemplateFileName = c.String(maxLength: 255),
                        CategoryUrlFormat = c.String(maxLength: 255, unicode: false),
                        ContentUrlFormat = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Models", t => t.ModelId, cascadeDelete: true)
                .Index(t => t.ModelId)
                .Index(t => t.Path);
            
            CreateTable(
                "dbo.CMS_Users",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserName = c.String(nullable: false, maxLength: 50),
                        PassWord = c.String(nullable: false, maxLength: 32, unicode: false),
                        LastLoginIP = c.String(maxLength: 16),
                        LastLoginTime = c.DateTime(),
                        LoginTimes = c.Int(nullable: false),
                        IsAdmin = c.Boolean(nullable: false),
                        HomePage = c.String(maxLength: 255),
                        QQ = c.String(maxLength: 50, unicode: false),
                        PetName = c.String(maxLength: 50),
                        Introduce = c.String(maxLength: 255),
                        EMail = c.String(maxLength: 150),
                        Coin = c.Int(nullable: false),
                        Point = c.Int(nullable: false),
                        Experience = c.Int(nullable: false),
                        Mature = c.DateTime(),
                        Question = c.String(maxLength: 255),
                        Answer = c.String(maxLength: 255),
                        Sex = c.Byte(nullable: false),
                        ActiveType = c.Byte(nullable: false),
                        RegTime = c.DateTime(),
                        IsLocked = c.Int(nullable: false),
                        TrueName = c.String(maxLength: 50),
                        Msn = c.String(maxLength: 50),
                        Birthday = c.String(maxLength: 50),
                        Province = c.String(maxLength: 50),
                        City = c.String(maxLength: 50),
                        Icq = c.String(maxLength: 12, unicode: false),
                        Yahoo = c.String(maxLength: 40, unicode: false),
                        Skype = c.String(maxLength: 40, unicode: false),
                        Location = c.String(maxLength: 50),
                        IdCard = c.String(maxLength: 20, unicode: false),
                        Mobile = c.String(maxLength: 20, unicode: false),
                        Phone = c.String(maxLength: 20, unicode: false),
                        Address = c.String(maxLength: 255),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.UserName)
                .Index(t => t.IsAdmin);
            
            CreateTable(
                "dbo.CMS_Businesses",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserId = c.Int(nullable: false),
                        Indent = c.Int(nullable: false),
                        Point = c.Int(nullable: false),
                        PayMoney = c.Decimal(nullable: false, precision: 19, scale: 4),
                        Customer = c.String(nullable: false, maxLength: 50),
                        CreateTime = c.DateTime(nullable: false),
                        Remark = c.String(nullable: false, maxLength: 500),
                        Flag = c.Byte(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Users", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.CMS_Rights",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 36, fixedLength: true, unicode: false),
                        ModelId = c.String(maxLength: 50, unicode: false),
                        Name = c.String(maxLength: 50),
                        Code = c.String(maxLength: 50),
                        OldCode = c.String(maxLength: 50),
                        RootId = c.Int(nullable: false),
                        OrderId = c.Int(nullable: false),
                        ParentId = c.String(maxLength: 50, unicode: false),
                        IsAdmin = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Roles",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        RoleName = c.String(nullable: false, maxLength: 50),
                        Remark = c.String(nullable: false, maxLength: 100),
                        Rank = c.Int(nullable: false),
                        IsAdmin = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_UserAddresses",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserId = c.Int(nullable: false),
                        NickName = c.String(maxLength: 50),
                        Email = c.String(maxLength: 255),
                        Address = c.String(maxLength: 200),
                        PostCode = c.String(maxLength: 50),
                        Tel = c.String(maxLength: 50),
                        Moblie = c.String(maxLength: 50),
                        Flag = c.String(maxLength: 50),
                        BestTime = c.String(maxLength: 100),
                        IsDefault = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Users", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.CMS_Comments",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ReplyId = c.Int(),
                        ModelId = c.Byte(nullable: false),
                        ContentId = c.Int(nullable: false),
                        UserName = c.String(maxLength: 50),
                        Score = c.Decimal(nullable: false, precision: 18, scale: 1),
                        Content = c.String(nullable: false, maxLength: 255),
                        Pass = c.Boolean(nullable: false),
                        IP = c.String(nullable: false, maxLength: 50, unicode: false),
                        Support = c.Int(nullable: false),
                        Oppose = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        UpdateTime = c.DateTime(nullable: false),
                        Floor = c.Int(),
                        MaxFloor = c.Int(),
                        Path = c.String(maxLength: 1000, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Cores", t => t.ContentId, cascadeDelete: true)
                .Index(t => t.ReplyId)
                .Index(t => t.ContentId);
            
            CreateTable(
                "dbo.CMS_Diggs",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ContentId = c.Int(nullable: false),
                        GoodNum = c.Int(nullable: false),
                        BadNum = c.Int(nullable: false),
                        LastUserName = c.String(nullable: false, maxLength: 50),
                        LastDiggDate = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Cores", t => t.ContentId, cascadeDelete: true)
                .Index(t => t.ContentId);
            
            CreateTable(
                "dbo.CMS_DiggDiaries",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        DiggId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        IsReg = c.Boolean(nullable: false),
                        IsAgree = c.Boolean(nullable: false),
                        IP = c.String(nullable: false, maxLength: 32, unicode: false),
                        CheckInDate = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Diggs", t => t.DiggId, cascadeDelete: true)
                .Index(t => t.DiggId);
            
            CreateTable(
                "dbo.CMS_Specials",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SpecialName = c.String(nullable: false, maxLength: 50),
                        SpecialNameEN = c.String(maxLength: 50, unicode: false),
                        ParentId = c.Int(nullable: false),
                        OrderId = c.Int(nullable: false),
                        LinkUrl = c.String(maxLength: 300),
                        Path = c.String(maxLength: 50, unicode: false),
                        DomainName = c.String(maxLength: 255),
                        ContentAdmin = c.String(maxLength: 1000),
                        SpecialAdmin = c.String(maxLength: 1000),
                        SpecialFilePostfix = c.String(maxLength: 10),
                        SpecialFilePrefix = c.String(maxLength: 10),
                        SpecialURLStyle = c.Int(nullable: false),
                        SpecialIntro = c.String(maxLength: 255),
                        SpecialPic = c.String(maxLength: 255),
                        SpecialDescription = c.String(maxLength: 255),
                        SpecialKeyWord = c.String(maxLength: 255),
                        OpenGrade = c.Int(nullable: false),
                        SpeciaURLFormat = c.String(maxLength: 255, unicode: false),
                        TemplateFileName = c.String(maxLength: 255),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Tags",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Byte(nullable: false),
                        TagName = c.String(nullable: false, maxLength: 50),
                        Counts = c.Long(),
                        ViewCounts = c.Long(),
                        UserId = c.Int(),
                        Flag = c.Byte(),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.ModelId)
                .Index(t => t.TagName);
            
            CreateTable(
                "dbo.CMS_Brands",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(maxLength: 50),
                        SrcList = c.String(maxLength: 255),
                        SrcDetail = c.String(maxLength: 255),
                        Website = c.String(maxLength: 255),
                        OrderId = c.Int(),
                        Content = c.String(maxLength: 1000),
                        IsShow = c.Int(),
                        Title = c.String(maxLength: 100),
                        Keywords = c.String(maxLength: 255),
                        Description = c.String(maxLength: 255),
                        Pinyin = c.String(maxLength: 100),
                        Company = c.String(maxLength: 100),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_ShoppingCarts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        GoodsId = c.Int(nullable: false),
                        Quantity = c.Int(nullable: false),
                        CartGUID = c.String(nullable: false, maxLength: 50),
                        CheckInDate = c.DateTime(nullable: false),
                        IsBundling = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Goods", t => t.GoodsId)
                .Index(t => t.GoodsId);
            
            CreateTable(
                "dbo.CMS_PhotoLists",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ContentId = c.Int(nullable: false),
                        Title = c.String(maxLength: 50),
                        ThumbUrl = c.String(nullable: false, maxLength: 255, unicode: false),
                        PicUrl = c.String(nullable: false, maxLength: 255, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        UpdateTime = c.DateTime(nullable: false),
                        TempFlag = c.String(maxLength: 36, unicode: false),
                        OrderId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Photos", t => t.ContentId)
                .Index(t => new { t.OrderId, t.ContentId }, name: "IX_PhotoList");
            
            CreateTable(
                "dbo.CMS_SoftDownLists",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Byte(nullable: false),
                        SoftId = c.Int(nullable: false),
                        ServerId = c.Int(nullable: false),
                        FileName = c.String(nullable: false, maxLength: 200),
                        DownLinkName = c.String(nullable: false, maxLength: 200),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_SoftServers", t => t.ServerId, cascadeDelete: true)
                .ForeignKey("dbo.CMS_Softs", t => t.SoftId)
                .Index(t => t.SoftId)
                .Index(t => t.ServerId);
            
            CreateTable(
                "dbo.CMS_SoftServers",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Int(nullable: false),
                        ServerName = c.String(nullable: false, maxLength: 255),
                        DownURL = c.String(nullable: false, maxLength: 255),
                        LinkProperty = c.Int(nullable: false),
                        ParentId = c.Int(),
                        RootId = c.Int(nullable: false),
                        OrderId = c.Int(nullable: false),
                        IsLock = c.Boolean(nullable: false),
                        ServerHTML = c.String(nullable: false, maxLength: 255),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_SoftLinkErrs",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SoftId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        Message = c.String(nullable: false, maxLength: 255),
                        IP = c.String(nullable: false, maxLength: 16),
                        UpDateTime = c.DateTime(nullable: false),
                        Complete = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Softs", t => t.SoftId)
                .Index(t => t.SoftId);
            
            CreateTable(
                "dbo.CMS_Gathers",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(maxLength: 50),
                        StartUrl = c.String(unicode: false),
                        CategoryArea = c.String(maxLength: 2000),
                        ContentTitle = c.String(maxLength: 2000),
                        UpdateTime = c.String(maxLength: 2000),
                        ComeFrom = c.String(maxLength: 2000),
                        Author = c.String(maxLength: 2000),
                        Content = c.String(maxLength: 2000),
                        ContentPageUrl = c.String(maxLength: 2000),
                        FullArticleUrl = c.String(maxLength: 2000),
                        CategoryPageNextUrl = c.String(maxLength: 2000),
                        ContentPageNextUrl = c.String(maxLength: 2000),
                        IgnoreUrl = c.String(maxLength: 2000),
                        Filter = c.String(maxLength: 4000),
                        Replace = c.String(maxLength: 4000),
                        CanDownImg = c.Boolean(nullable: false),
                        CategoryId = c.Int(nullable: false),
                        LastWork = c.DateTime(),
                        IsChecked = c.Boolean(nullable: false),
                        CanDrawWaterMark = c.Boolean(nullable: false),
                        IsExpert = c.Boolean(nullable: false),
                        PID = c.Int(nullable: false),
                        IsDisabled = c.Boolean(nullable: false),
                        CheckInTime = c.DateTime(nullable: false),
                        Encoding = c.String(maxLength: 50, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Categories", t => t.CategoryId, cascadeDelete: true)
                .Index(t => new { t.Id, t.PID, t.IsDisabled }, name: "IX_Gather")
                .Index(t => t.CategoryId);
            
            CreateTable(
                "dbo.CMS_Models",
                c => new
                    {
                        Id = c.Byte(nullable: false),
                        ModelName = c.String(maxLength: 50),
                        DataTable = c.String(maxLength: 50, unicode: false),
                        BaseModel = c.String(maxLength: 50),
                        ContentName = c.String(maxLength: 50),
                        ContentUnit = c.String(maxLength: 50),
                        Filter = c.String(maxLength: 4000),
                        Remark = c.String(maxLength: 255),
                        HtmlSavePath = c.String(maxLength: 255),
                        MaxCategoryPageNo = c.Byte(nullable: false),
                        AdminUploadPath = c.String(maxLength: 255),
                        AdminUploadSize = c.Short(),
                        AdminFileTypes = c.String(maxLength: 1000),
                        EnableMemberUpload = c.Boolean(),
                        MemberUploadPath = c.String(maxLength: 255),
                        MemberUploadSize = c.Short(),
                        MemberFileTypes = c.String(maxLength: 1000),
                        AdminPass = c.Boolean(nullable: false),
                        CommentAutoPass = c.Boolean(nullable: false),
                        Contribution = c.Boolean(nullable: false),
                        SearchOption = c.Byte(nullable: false),
                        IsShowNewSign = c.Byte(nullable: false),
                        NewSignKeep = c.Byte(nullable: false),
                        PageSize = c.Byte(nullable: false),
                        Hide = c.Boolean(),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.BaseModel)
                .Index(t => t.Hide);
            
            CreateTable(
                "dbo.CMS_Memus",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 36, unicode: false),
                        Title = c.String(nullable: false, maxLength: 50),
                        Link = c.String(nullable: false, maxLength: 255, unicode: false),
                        Pid = c.String(nullable: false, maxLength: 36, unicode: false),
                        RootId = c.Int(nullable: false),
                        OrderId = c.Int(nullable: false),
                        BaseModel = c.String(nullable: false, maxLength: 50, unicode: false),
                        IsOpen = c.Boolean(nullable: false),
                        ModelId = c.Byte(),
                        LowestRightCode = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Models", t => t.ModelId)
                .Index(t => new { t.BaseModel, t.Link }, name: "IX_Memu")
                .Index(t => t.BaseModel)
                .Index(t => t.ModelId);
            
            CreateTable(
                "dbo.CMS_BankrollLists",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserName = c.String(nullable: false, maxLength: 50),
                        ClientId = c.Int(nullable: false),
                        Money = c.Decimal(nullable: false, precision: 19, scale: 4),
                        MoneyType = c.Int(nullable: false),
                        CurrencyType = c.Int(nullable: false),
                        EBankId = c.Int(nullable: false),
                        Bank = c.String(nullable: false, maxLength: 50),
                        IncomePayOut = c.Int(nullable: false),
                        OrderId = c.Int(nullable: false),
                        PaymentId = c.Int(nullable: false),
                        Remark = c.String(nullable: false, maxLength: 255),
                        LogTime = c.DateTime(nullable: false),
                        Admin = c.String(nullable: false, maxLength: 50),
                        IP = c.String(nullable: false, maxLength: 50),
                        CheckInDate = c.DateTime(nullable: false),
                        Deleted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Orders", t => t.OrderId, cascadeDelete: true)
                .Index(t => t.OrderId);
            
            CreateTable(
                "dbo.CMS_Orders",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        OrderNum = c.String(nullable: false, maxLength: 50),
                        UserName = c.String(nullable: false, maxLength: 50),
                        MoneyTotal = c.Decimal(nullable: false, precision: 19, scale: 4),
                        MoneyGoods = c.Decimal(nullable: false, precision: 19, scale: 4),
                        MoneyReceived = c.Decimal(nullable: false, precision: 19, scale: 4),
                        NeedInvoice = c.Boolean(nullable: false),
                        Invoiced = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 1000),
                        ContacterName = c.String(maxLength: 50),
                        Address = c.String(maxLength: 255),
                        ZipCode = c.String(maxLength: 50),
                        Mobile = c.String(maxLength: 50),
                        Phone = c.String(maxLength: 50),
                        Email = c.String(maxLength: 50),
                        PaymentType = c.Int(nullable: false),
                        DeliverType = c.Int(nullable: false),
                        Status = c.Int(nullable: false),
                        DeliverStatus = c.Int(nullable: false),
                        PayStatus = c.Int(nullable: false),
                        PresentExp = c.Int(nullable: false),
                        ChargeDeliver = c.Decimal(nullable: false, precision: 19, scale: 4),
                        InvoiceContent = c.String(maxLength: 1000),
                        CheckInDate = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_PriceChanges",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        OrderId = c.Int(nullable: false),
                        OldPrice = c.Decimal(nullable: false, precision: 19, scale: 4),
                        NewPrice = c.Decimal(nullable: false, precision: 19, scale: 4),
                        Admin = c.Int(nullable: false),
                        IP = c.String(nullable: false, maxLength: 50, unicode: false),
                        CheckInDate = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Orders", t => t.OrderId, cascadeDelete: true)
                .Index(t => t.OrderId);
            
            CreateTable(
                "dbo.CMS_Banks",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        BankName = c.String(maxLength: 20),
                        BankFullName = c.String(maxLength: 50),
                        HolderName = c.String(maxLength: 20),
                        Accounts = c.String(maxLength: 30),
                        CardNum = c.String(maxLength: 30),
                        Intro = c.String(maxLength: 255),
                        IsDefault = c.Boolean(nullable: false),
                        OrderId = c.Int(),
                        Pass = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Consultants",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Byte(nullable: false),
                        ContentId = c.Int(nullable: false),
                        ConsultTime = c.DateTime(nullable: false),
                        Content = c.String(nullable: false, maxLength: 2000),
                        UserName = c.String(maxLength: 255),
                        ReplyContent = c.String(maxLength: 2000),
                        ReplyTime = c.DateTime(),
                        Replier = c.String(maxLength: 255),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_ContentKeyWords",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(nullable: false, maxLength: 50),
                        Url = c.String(nullable: false, maxLength: 255, unicode: false),
                        Target = c.String(nullable: false, maxLength: 50, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        UpDateTime = c.DateTime(nullable: false),
                        IsClose = c.Boolean(nullable: false),
                        IgnoreCase = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_ContentProperties",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Byte(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        UpDateTime = c.DateTime(nullable: false),
                        Type = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_CounterContents",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Today = c.Long(nullable: false),
                        Yesterday = c.Long(nullable: false),
                        Date = c.DateTime(nullable: false),
                        Total = c.Long(nullable: false),
                        StartTime = c.DateTime(nullable: false),
                        High = c.Long(nullable: false),
                        HighTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_CounterDiaries",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Year = c.Int(nullable: false),
                        Month = c.Int(nullable: false),
                        Day = c.Int(nullable: false),
                        Hour = c.Int(nullable: false),
                        Time = c.DateTime(nullable: false),
                        Week = c.Int(nullable: false),
                        IP = c.String(maxLength: 50),
                        Where = c.String(maxLength: 250),
                        Where2 = c.String(maxLength: 50),
                        Come = c.String(maxLength: 250),
                        Page = c.String(maxLength: 250),
                        Browser = c.String(maxLength: 50),
                        OS = c.String(maxLength: 50),
                        Resolution = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => new { t.Year, t.Month, t.Day, t.Hour, t.Week }, name: "IX_CounterDiary_YM")
                .Index(t => new { t.Where, t.Time }, name: "IX_CounterDiary")
                .Index(t => new { t.Come, t.Time }, name: "IX_CounterDiary_Come")
                .Index(t => new { t.Time, t.IP }, name: "IX_CounterDiary_Time")
                .Index(t => new { t.Page, t.Time }, name: "IX_CounterDiary_Page");
            
            CreateTable(
                "dbo.CMS_Deliveries",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        OrderId = c.Int(nullable: false),
                        DeliverDate = c.DateTime(nullable: false),
                        DeliverDirection = c.Int(nullable: false),
                        HandlerName = c.String(maxLength: 50),
                        ExpressCompany = c.String(maxLength: 50),
                        ExpressNumber = c.String(maxLength: 50),
                        Admin = c.Int(nullable: false),
                        Remark = c.String(maxLength: 255),
                        Served = c.Int(nullable: false),
                        CheckInDate = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_DeliveryAreas",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        DeliveryMethodId = c.Int(),
                        Name = c.String(nullable: false, maxLength: 50),
                        Remark = c.String(maxLength: 255),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_DeliveryMethods",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        MethodName = c.String(nullable: false, maxLength: 50),
                        Intro = c.String(nullable: false, maxLength: 255),
                        IsDefault = c.Boolean(nullable: false),
                        Pass = c.Int(nullable: false),
                        OrderId = c.Int(nullable: false),
                        Charge = c.Decimal(nullable: false, precision: 19, scale: 4),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_ExtensionCategories",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        ParentId = c.Int(),
                        RootId = c.Int(),
                        OrderId = c.Int(),
                        Path = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_ExtensionCategoryLists",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Int(nullable: false),
                        Ecid = c.Int(nullable: false),
                        ContentId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Favorites",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(nullable: false, maxLength: 100),
                        Url = c.String(nullable: false, maxLength: 255),
                        UserId = c.Int(nullable: false),
                        Visit = c.Int(nullable: false),
                        Updatetime = c.DateTime(),
                        LastVisit = c.DateTime(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Fields",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Byte(nullable: false),
                        FieldName = c.String(nullable: false, maxLength: 50),
                        Title = c.String(nullable: false, maxLength: 255),
                        Tips = c.String(maxLength: 255),
                        FieldType = c.String(maxLength: 255),
                        DefaultValue = c.String(maxLength: 4000),
                        ControlType = c.String(maxLength: 50),
                        IsShowInMember = c.Boolean(nullable: false),
                        OrderId = c.Int(nullable: false),
                        Indispensable = c.Int(nullable: false),
                        Width = c.Int(nullable: false),
                        MaxFieldLength = c.Int(nullable: false),
                        IsStop = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_FriendLinks",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(nullable: false, maxLength: 50),
                        Logo = c.String(nullable: false, maxLength: 100),
                        Url = c.String(nullable: false, maxLength: 100),
                        OrderId = c.Int(nullable: false),
                        Pass = c.Boolean(nullable: false),
                        Password = c.String(nullable: false, maxLength: 32, fixedLength: true, unicode: false),
                        UpdateTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_GatherHistories",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Url = c.String(nullable: false, maxLength: 255, unicode: false),
                        CheckInTime = c.DateTime(nullable: false),
                        Md5 = c.String(nullable: false, maxLength: 32, fixedLength: true, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.CheckInTime)
                .Index(t => t.Md5);
            
            CreateTable(
                "dbo.CMS_GatherUrlCaches",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PUrlMD5 = c.String(nullable: false, maxLength: 32, fixedLength: true, unicode: false),
                        PUrl = c.String(nullable: false, maxLength: 255),
                        NextPageUrl = c.String(nullable: false, maxLength: 255),
                        CacheTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.PUrlMD5);
            
            CreateTable(
                "dbo.CMS_GoodsCustomFields",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Int(nullable: false),
                        CategoryId = c.Int(nullable: false),
                        FieldName = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_GoodsCustomFieldValues",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        GoodsId = c.Int(),
                        FieldId = c.Int(),
                        FieldName = c.String(maxLength: 50),
                        FieldValue = c.String(maxLength: 4000),
                        EnableSearch = c.Boolean(),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.GoodsId);
            
            CreateTable(
                "dbo.CMS_GoodsImgs",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        GoodsId = c.Int(),
                        Title = c.String(maxLength: 50),
                        PicUrl = c.String(maxLength: 255, unicode: false),
                        TempGUID = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_GoodsParts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ParentId = c.Int(),
                        GoodsId = c.Int(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_GuestBooks",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                        EMail = c.String(nullable: false, maxLength: 100),
                        QQ = c.String(nullable: false, maxLength: 50, unicode: false),
                        Home = c.String(nullable: false, maxLength: 255),
                        Face = c.String(nullable: false, maxLength: 50),
                        Humor = c.String(nullable: false, maxLength: 50),
                        Privacy = c.Int(nullable: false),
                        IP = c.String(nullable: false, maxLength: 16),
                        Content = c.String(nullable: false, maxLength: 2000),
                        Reply = c.String(nullable: false, maxLength: 2000),
                        CreateTime = c.DateTime(nullable: false),
                        UpdateTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Helps",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(maxLength: 50),
                        Content = c.String(),
                        Admin = c.String(maxLength: 50),
                        Pass = c.Boolean(nullable: false),
                        CheckInDate = c.DateTime(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_HotKeyWords",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ModelId = c.Byte(nullable: false),
                        KeyWord = c.String(nullable: false, maxLength: 100),
                        Hits = c.Int(nullable: false),
                        LastHitTime = c.DateTime(nullable: false),
                        Result = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Invoices",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ClientId = c.Int(nullable: false),
                        UserName = c.String(nullable: false, maxLength: 50),
                        OrderId = c.Int(nullable: false),
                        InvoiceType = c.Int(nullable: false),
                        InvoiceNum = c.String(nullable: false, maxLength: 50),
                        InvoiceTitle = c.String(nullable: false, maxLength: 50),
                        InvoiceContent = c.String(nullable: false),
                        InvoiceDate = c.DateTime(nullable: false),
                        TotalMoney = c.Decimal(nullable: false, precision: 19, scale: 4),
                        Drawer = c.String(nullable: false, maxLength: 50),
                        Admin = c.String(nullable: false, maxLength: 50),
                        CheckInDate = c.DateTime(nullable: false),
                        Deleted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_IPBlackLists",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        IPStart = c.String(nullable: false, maxLength: 16, fixedLength: true, unicode: false),
                        IPEnd = c.String(nullable: false, maxLength: 16, fixedLength: true, unicode: false),
                        SectorStart = c.Long(nullable: false),
                        SectorEnd = c.Long(nullable: false),
                        AdminName = c.String(nullable: false, maxLength: 50),
                        CreateTime = c.DateTime(nullable: false),
                        UpDateTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.IPStart)
                .Index(t => t.IPEnd)
                .Index(t => t.SectorStart)
                .Index(t => t.SectorEnd);
            
            CreateTable(
                "dbo.CMS_Logs",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserName = c.String(nullable: false, maxLength: 50),
                        Type = c.String(nullable: false, maxLength: 12),
                        Event = c.String(nullable: false, maxLength: 250),
                        CheckInDate = c.DateTime(nullable: false),
                        Deleted = c.Boolean(nullable: false),
                        PageName = c.String(nullable: false, maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => new { t.Type, t.Deleted }, name: "IX_Log_Type")
                .Index(t => t.Deleted);
            
            CreateTable(
                "dbo.CMS_Messages",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Sender = c.String(nullable: false, maxLength: 50),
                        Incept = c.String(nullable: false, maxLength: 50),
                        Title = c.String(nullable: false, maxLength: 100),
                        Content = c.String(nullable: false),
                        Flag = c.Byte(nullable: false),
                        SendTime = c.DateTime(nullable: false),
                        IsRead = c.Boolean(nullable: false),
                        DelSend = c.Boolean(nullable: false),
                        CloseTime = c.DateTime(),
                        GUID = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => new { t.Incept, t.IsRead }, name: "IX_Message")
                .Index(t => t.GUID);
            
            CreateTable(
                "dbo.CMS_OrderLists",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        OrderId = c.Int(nullable: false),
                        GoodsId = c.Int(nullable: false),
                        SaleType = c.Int(nullable: false),
                        OriginalPrice = c.Decimal(nullable: false, precision: 19, scale: 4),
                        Price = c.Decimal(nullable: false, precision: 19, scale: 4),
                        Quantity = c.Int(nullable: false),
                        SubTotal = c.Decimal(nullable: false, precision: 19, scale: 4),
                        PresentExp = c.Int(nullable: false),
                        Remark = c.String(nullable: false, maxLength: 1000),
                        CheckInDate = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_PaymentMethods",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        MethodName = c.String(maxLength: 50),
                        AccountsId = c.String(maxLength: 50),
                        Md5 = c.String(maxLength: 255),
                        Rate = c.Decimal(precision: 18, scale: 0),
                        OrderId = c.Int(),
                        Pass = c.Boolean(nullable: false),
                        IsDefault = c.Boolean(nullable: false),
                        Admin = c.String(nullable: false, maxLength: 50),
                        Interface = c.Int(),
                        ParentId = c.String(maxLength: 50),
                        EMail = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_SecurityCenters",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserName = c.String(nullable: false, maxLength: 50),
                        FilePath = c.String(nullable: false, maxLength: 255),
                        IP = c.String(nullable: false, maxLength: 16),
                        Type = c.Int(nullable: false),
                        UpDateTime = c.DateTime(nullable: false),
                        Remark = c.String(nullable: false, maxLength: 500),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_TaskActives",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Tasks",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        TaskName = c.String(nullable: false, maxLength: 50),
                        TaskActiveId = c.Int(nullable: false),
                        AwakenTime = c.DateTime(),
                        IntervalMinute = c.Int(nullable: false),
                        EveryDayTime = c.String(maxLength: 50, unicode: false),
                        Week = c.Int(),
                        UnexecuteType = c.Int(),
                        LastRunTime = c.DateTime(),
                        IsUsed = c.Boolean(nullable: false),
                        DLLName = c.String(maxLength: 100),
                        FullClassName = c.String(maxLength: 100),
                        CommandLine = c.String(maxLength: 100),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.FullClassName);
            
            CreateTable(
                "dbo.CMS_Templates",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 36, fixedLength: true, unicode: false),
                        TemplateName = c.String(maxLength: 50),
                        TemplatePath = c.String(maxLength: 50),
                        IsUsed = c.Boolean(),
                        Style = c.String(maxLength: 50),
                        Remark = c.String(maxLength: 100),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_UDTs",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                        DataSource = c.String(maxLength: 1000),
                        SqlScript = c.String(maxLength: 1000),
                        Type = c.Int(nullable: false),
                        JsPath = c.String(maxLength: 255),
                        Stop = c.Int(nullable: false),
                        URLType = c.String(maxLength: 50),
                        FirstItemTemplate = c.String(maxLength: 500),
                        SecondItemTemplate = c.String(maxLength: 500),
                        AlternatingItemTemplate = c.String(maxLength: 500),
                        SeparatorTemplate = c.String(maxLength: 500),
                        ItemTemplate = c.String(maxLength: 500),
                        HeaderTemplate = c.String(maxLength: 500),
                        FooterTemplate = c.String(maxLength: 500),
                        EmptyDataTemplate = c.String(maxLength: 500),
                        Tag = c.String(maxLength: 4000),
                        Remark = c.String(maxLength: 500),
                        CheckInTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => new { t.Id, t.Name });
            
            CreateTable(
                "dbo.CMS_Units",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                        CheckInDate = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_UserMoneys",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserId = c.Int(nullable: false),
                        UserName = c.String(maxLength: 50),
                        CheckIn = c.Decimal(precision: 19, scale: 4),
                        CheckOut = c.Decimal(precision: 19, scale: 4),
                        Balance = c.Decimal(precision: 19, scale: 4),
                        CheckInDate = c.DateTime(),
                        Remark = c.String(maxLength: 100),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Users", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.CMS_UserScores",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        OrderId = c.Int(),
                        UserId = c.Int(nullable: false),
                        UserName = c.String(maxLength: 50),
                        CheckIn = c.Int(),
                        CheckOut = c.Int(),
                        Balance = c.Int(),
                        CheckInDate = c.DateTime(),
                        Remark = c.String(maxLength: 100),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Users", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.CMS_VoteChoices",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ChoiceTitle = c.String(nullable: false, maxLength: 50),
                        VoteNum = c.Int(nullable: false),
                        PicUrl = c.String(maxLength: 255),
                        IsDefault = c.Boolean(nullable: false),
                        VoteId = c.Int(nullable: false),
                        OrderId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Votes", t => t.VoteId, cascadeDelete: true)
                .Index(t => t.VoteId);
            
            CreateTable(
                "dbo.CMS_Votes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(nullable: false, maxLength: 50),
                        Pass = c.Boolean(nullable: false),
                        VoteType = c.String(nullable: false, maxLength: 50),
                        PicUrl = c.String(maxLength: 255),
                        EndData = c.DateTime(),
                        Windowsize = c.String(maxLength: 50),
                        TemplateFileName = c.String(nullable: false, maxLength: 255),
                        LimitIP = c.Boolean(nullable: false),
                        CheckInTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Words",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Find = c.String(maxLength: 255),
                        Replacement = c.String(maxLength: 255),
                        Ban = c.Int(),
                        AdminName = c.String(maxLength: 50),
                        UpDateTime = c.DateTime(),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => new { t.Find, t.Ban }, name: "IX_Words_FB")
                .Index(t => t.Ban);
            
            CreateTable(
                "dbo.CMS_RoleCategories",
                c => new
                    {
                        Role_Id = c.Int(nullable: false),
                        Category_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Role_Id, t.Category_Id })
                .ForeignKey("dbo.CMS_Roles", t => t.Role_Id, cascadeDelete: true)
                .ForeignKey("dbo.CMS_Categories", t => t.Category_Id, cascadeDelete: true)
                .Index(t => t.Role_Id)
                .Index(t => t.Category_Id);
            
            CreateTable(
                "dbo.CMS_RoleUsers",
                c => new
                    {
                        Role_Id = c.Int(nullable: false),
                        User_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Role_Id, t.User_Id })
                .ForeignKey("dbo.CMS_Roles", t => t.Role_Id, cascadeDelete: true)
                .ForeignKey("dbo.CMS_Users", t => t.User_Id, cascadeDelete: true)
                .Index(t => t.Role_Id)
                .Index(t => t.User_Id);
            
            CreateTable(
                "dbo.CMS_RightRoles",
                c => new
                    {
                        Right_Id = c.String(nullable: false, maxLength: 36, fixedLength: true, unicode: false),
                        Role_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Right_Id, t.Role_Id })
                .ForeignKey("dbo.CMS_Rights", t => t.Right_Id, cascadeDelete: true)
                .ForeignKey("dbo.CMS_Roles", t => t.Role_Id, cascadeDelete: true)
                .Index(t => t.Right_Id)
                .Index(t => t.Role_Id);
            
            CreateTable(
                "dbo.CMS_RightUsers",
                c => new
                    {
                        Right_Id = c.String(nullable: false, maxLength: 36, fixedLength: true, unicode: false),
                        User_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Right_Id, t.User_Id })
                .ForeignKey("dbo.CMS_Rights", t => t.Right_Id, cascadeDelete: true)
                .ForeignKey("dbo.CMS_Users", t => t.User_Id, cascadeDelete: true)
                .Index(t => t.Right_Id)
                .Index(t => t.User_Id);
            
            CreateTable(
                "dbo.CMS_CategoryUsers",
                c => new
                    {
                        Category_Id = c.Int(nullable: false),
                        User_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Category_Id, t.User_Id })
                .ForeignKey("dbo.CMS_Categories", t => t.Category_Id, cascadeDelete: true)
                .ForeignKey("dbo.CMS_Users", t => t.User_Id, cascadeDelete: true)
                .Index(t => t.Category_Id)
                .Index(t => t.User_Id);
            
            CreateTable(
                "dbo.CMS_CoreCategories",
                c => new
                    {
                        Core_Id = c.Int(nullable: false),
                        Category_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Core_Id, t.Category_Id })
                .ForeignKey("dbo.CMS_Cores", t => t.Core_Id, cascadeDelete: true)
                .ForeignKey("dbo.CMS_Categories", t => t.Category_Id, cascadeDelete: true)
                .Index(t => t.Core_Id)
                .Index(t => t.Category_Id);
            
            CreateTable(
                "dbo.CMS_CoreSpecials",
                c => new
                    {
                        Core_Id = c.Int(nullable: false),
                        Special_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Core_Id, t.Special_Id })
                .ForeignKey("dbo.CMS_Cores", t => t.Core_Id, cascadeDelete: true)
                .ForeignKey("dbo.CMS_Specials", t => t.Special_Id, cascadeDelete: true)
                .Index(t => t.Core_Id)
                .Index(t => t.Special_Id);
            
            CreateTable(
                "dbo.CMS_CoreTags",
                c => new
                    {
                        Core_Id = c.Int(nullable: false),
                        Tag_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Core_Id, t.Tag_Id })
                .ForeignKey("dbo.CMS_Cores", t => t.Core_Id, cascadeDelete: true)
                .ForeignKey("dbo.CMS_Tags", t => t.Tag_Id, cascadeDelete: true)
                .Index(t => t.Core_Id)
                .Index(t => t.Tag_Id);
            
            CreateTable(
                "dbo.CMS_Articles",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        Subtitle = c.String(nullable: false, maxLength: 200),
                        Content = c.String(nullable: false),
                        Author = c.String(nullable: false, maxLength: 50),
                        ComeFrom = c.String(nullable: false, maxLength: 200),
                        SEOTitle = c.String(maxLength: 255),
                        SEOKeyWord = c.String(maxLength: 255),
                        SEODescript = c.String(maxLength: 255),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Cores", t => t.Id)
                .Index(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Goods",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        GoodsNum = c.String(nullable: false, maxLength: 20),
                        Brand = c.String(maxLength: 50),
                        BrandId = c.Int(nullable: false),
                        Standard = c.String(nullable: false, maxLength: 100),
                        Packaging = c.String(nullable: false, maxLength: 100),
                        BarCode = c.String(nullable: false, maxLength: 50, unicode: false),
                        Content = c.String(nullable: false),
                        PriceMarket = c.Decimal(nullable: false, precision: 19, scale: 4),
                        PriceMember = c.Decimal(nullable: false, precision: 19, scale: 4),
                        Unit = c.String(nullable: false, maxLength: 5),
                        BigPicUrl = c.String(nullable: false, maxLength: 255, unicode: false),
                        Discount = c.Decimal(nullable: false, precision: 18, scale: 4),
                        PresentExp = c.Int(nullable: false),
                        Stocks = c.Int(nullable: false),
                        AlarmNum = c.Int(nullable: false),
                        BuyTimes = c.Int(nullable: false),
                        Weight = c.Decimal(nullable: false, precision: 18, scale: 4),
                        IsSpecialPrice = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Cores", t => t.Id)
                .ForeignKey("dbo.CMS_Brands", t => t.BrandId, cascadeDelete: true)
                .Index(t => t.Id)
                .Index(t => t.BrandId);
            
            CreateTable(
                "dbo.CMS_Photos",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        Content = c.String(nullable: false),
                        Author = c.String(nullable: false, maxLength: 50),
                        ComeFrom = c.String(nullable: false, maxLength: 200),
                        SEOTitle = c.String(maxLength: 255),
                        SEOKeyWord = c.String(maxLength: 255),
                        SEODescript = c.String(maxLength: 255),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Cores", t => t.Id)
                .Index(t => t.Id);
            
            CreateTable(
                "dbo.CMS_Softs",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        SoftVersion = c.String(nullable: false, maxLength: 50, unicode: false),
                        SoftSize = c.String(nullable: false, maxLength: 50, unicode: false),
                        Content = c.String(nullable: false),
                        DemoUrl = c.String(nullable: false, maxLength: 300),
                        Author = c.String(nullable: false, maxLength: 50),
                        Email = c.String(nullable: false, maxLength: 100),
                        Homepage = c.String(nullable: false, maxLength: 300),
                        RunAtSystem = c.String(nullable: false, maxLength: 100),
                        SoftType = c.String(nullable: false, maxLength: 50),
                        SoftLanguage = c.String(nullable: false, maxLength: 50),
                        CopyrightType = c.String(nullable: false, maxLength: 50),
                        DecompressPassword = c.String(nullable: false, maxLength: 100),
                        BlackGuard = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CMS_Cores", t => t.Id)
                .Index(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.CMS_Softs", "Id", "dbo.CMS_Cores");
            DropForeignKey("dbo.CMS_Photos", "Id", "dbo.CMS_Cores");
            DropForeignKey("dbo.CMS_Goods", "BrandId", "dbo.CMS_Brands");
            DropForeignKey("dbo.CMS_Goods", "Id", "dbo.CMS_Cores");
            DropForeignKey("dbo.CMS_Articles", "Id", "dbo.CMS_Cores");
            DropForeignKey("dbo.CMS_VoteChoices", "VoteId", "dbo.CMS_Votes");
            DropForeignKey("dbo.CMS_UserScores", "UserId", "dbo.CMS_Users");
            DropForeignKey("dbo.CMS_UserMoneys", "UserId", "dbo.CMS_Users");
            DropForeignKey("dbo.CMS_Areas", "DeliveryArea_Id", "dbo.CMS_DeliveryAreas");
            DropForeignKey("dbo.CMS_BankrollLists", "OrderId", "dbo.CMS_Orders");
            DropForeignKey("dbo.CMS_PriceChanges", "OrderId", "dbo.CMS_Orders");
            DropForeignKey("dbo.CMS_Categories", "ModelId", "dbo.CMS_Models");
            DropForeignKey("dbo.CMS_Memus", "ModelId", "dbo.CMS_Models");
            DropForeignKey("dbo.CMS_Gathers", "CategoryId", "dbo.CMS_Categories");
            DropForeignKey("dbo.CMS_SoftLinkErrs", "SoftId", "dbo.CMS_Softs");
            DropForeignKey("dbo.CMS_SoftDownLists", "SoftId", "dbo.CMS_Softs");
            DropForeignKey("dbo.CMS_SoftDownLists", "ServerId", "dbo.CMS_SoftServers");
            DropForeignKey("dbo.CMS_PhotoLists", "ContentId", "dbo.CMS_Photos");
            DropForeignKey("dbo.CMS_ShoppingCarts", "GoodsId", "dbo.CMS_Goods");
            DropForeignKey("dbo.CMS_CoreTags", "Tag_Id", "dbo.CMS_Tags");
            DropForeignKey("dbo.CMS_CoreTags", "Core_Id", "dbo.CMS_Cores");
            DropForeignKey("dbo.CMS_CoreSpecials", "Special_Id", "dbo.CMS_Specials");
            DropForeignKey("dbo.CMS_CoreSpecials", "Core_Id", "dbo.CMS_Cores");
            DropForeignKey("dbo.CMS_DiggDiaries", "DiggId", "dbo.CMS_Diggs");
            DropForeignKey("dbo.CMS_Diggs", "ContentId", "dbo.CMS_Cores");
            DropForeignKey("dbo.CMS_CoreCategories", "Category_Id", "dbo.CMS_Categories");
            DropForeignKey("dbo.CMS_CoreCategories", "Core_Id", "dbo.CMS_Cores");
            DropForeignKey("dbo.CMS_Comments", "ContentId", "dbo.CMS_Cores");
            DropForeignKey("dbo.CMS_Cores", "CategoryId", "dbo.CMS_Categories");
            DropForeignKey("dbo.CMS_CategoryUsers", "User_Id", "dbo.CMS_Users");
            DropForeignKey("dbo.CMS_CategoryUsers", "Category_Id", "dbo.CMS_Categories");
            DropForeignKey("dbo.CMS_UserAddresses", "UserId", "dbo.CMS_Users");
            DropForeignKey("dbo.CMS_RightUsers", "User_Id", "dbo.CMS_Users");
            DropForeignKey("dbo.CMS_RightUsers", "Right_Id", "dbo.CMS_Rights");
            DropForeignKey("dbo.CMS_RightRoles", "Role_Id", "dbo.CMS_Roles");
            DropForeignKey("dbo.CMS_RightRoles", "Right_Id", "dbo.CMS_Rights");
            DropForeignKey("dbo.CMS_RoleUsers", "User_Id", "dbo.CMS_Users");
            DropForeignKey("dbo.CMS_RoleUsers", "Role_Id", "dbo.CMS_Roles");
            DropForeignKey("dbo.CMS_RoleCategories", "Category_Id", "dbo.CMS_Categories");
            DropForeignKey("dbo.CMS_RoleCategories", "Role_Id", "dbo.CMS_Roles");
            DropForeignKey("dbo.CMS_Businesses", "UserId", "dbo.CMS_Users");
            DropIndex("dbo.CMS_Softs", new[] { "Id" });
            DropIndex("dbo.CMS_Photos", new[] { "Id" });
            DropIndex("dbo.CMS_Goods", new[] { "BrandId" });
            DropIndex("dbo.CMS_Goods", new[] { "Id" });
            DropIndex("dbo.CMS_Articles", new[] { "Id" });
            DropIndex("dbo.CMS_CoreTags", new[] { "Tag_Id" });
            DropIndex("dbo.CMS_CoreTags", new[] { "Core_Id" });
            DropIndex("dbo.CMS_CoreSpecials", new[] { "Special_Id" });
            DropIndex("dbo.CMS_CoreSpecials", new[] { "Core_Id" });
            DropIndex("dbo.CMS_CoreCategories", new[] { "Category_Id" });
            DropIndex("dbo.CMS_CoreCategories", new[] { "Core_Id" });
            DropIndex("dbo.CMS_CategoryUsers", new[] { "User_Id" });
            DropIndex("dbo.CMS_CategoryUsers", new[] { "Category_Id" });
            DropIndex("dbo.CMS_RightUsers", new[] { "User_Id" });
            DropIndex("dbo.CMS_RightUsers", new[] { "Right_Id" });
            DropIndex("dbo.CMS_RightRoles", new[] { "Role_Id" });
            DropIndex("dbo.CMS_RightRoles", new[] { "Right_Id" });
            DropIndex("dbo.CMS_RoleUsers", new[] { "User_Id" });
            DropIndex("dbo.CMS_RoleUsers", new[] { "Role_Id" });
            DropIndex("dbo.CMS_RoleCategories", new[] { "Category_Id" });
            DropIndex("dbo.CMS_RoleCategories", new[] { "Role_Id" });
            DropIndex("dbo.CMS_Words", new[] { "Ban" });
            DropIndex("dbo.CMS_Words", "IX_Words_FB");
            DropIndex("dbo.CMS_VoteChoices", new[] { "VoteId" });
            DropIndex("dbo.CMS_UserScores", new[] { "UserId" });
            DropIndex("dbo.CMS_UserMoneys", new[] { "UserId" });
            DropIndex("dbo.CMS_Tasks", new[] { "FullClassName" });
            DropIndex("dbo.CMS_Messages", new[] { "GUID" });
            DropIndex("dbo.CMS_Messages", "IX_Message");
            DropIndex("dbo.CMS_Logs", new[] { "Deleted" });
            DropIndex("dbo.CMS_Logs", "IX_Log_Type");
            DropIndex("dbo.CMS_IPBlackLists", new[] { "SectorEnd" });
            DropIndex("dbo.CMS_IPBlackLists", new[] { "SectorStart" });
            DropIndex("dbo.CMS_IPBlackLists", new[] { "IPEnd" });
            DropIndex("dbo.CMS_IPBlackLists", new[] { "IPStart" });
            DropIndex("dbo.CMS_GoodsCustomFieldValues", new[] { "GoodsId" });
            DropIndex("dbo.CMS_GatherUrlCaches", new[] { "PUrlMD5" });
            DropIndex("dbo.CMS_GatherHistories", new[] { "Md5" });
            DropIndex("dbo.CMS_GatherHistories", new[] { "CheckInTime" });
            DropIndex("dbo.CMS_CounterDiaries", "IX_CounterDiary_Page");
            DropIndex("dbo.CMS_CounterDiaries", "IX_CounterDiary_Time");
            DropIndex("dbo.CMS_CounterDiaries", "IX_CounterDiary_Come");
            DropIndex("dbo.CMS_CounterDiaries", "IX_CounterDiary");
            DropIndex("dbo.CMS_CounterDiaries", "IX_CounterDiary_YM");
            DropIndex("dbo.CMS_PriceChanges", new[] { "OrderId" });
            DropIndex("dbo.CMS_BankrollLists", new[] { "OrderId" });
            DropIndex("dbo.CMS_Memus", new[] { "ModelId" });
            DropIndex("dbo.CMS_Memus", new[] { "BaseModel" });
            DropIndex("dbo.CMS_Memus", "IX_Memu");
            DropIndex("dbo.CMS_Models", new[] { "Hide" });
            DropIndex("dbo.CMS_Models", new[] { "BaseModel" });
            DropIndex("dbo.CMS_Gathers", new[] { "CategoryId" });
            DropIndex("dbo.CMS_Gathers", "IX_Gather");
            DropIndex("dbo.CMS_SoftLinkErrs", new[] { "SoftId" });
            DropIndex("dbo.CMS_SoftDownLists", new[] { "ServerId" });
            DropIndex("dbo.CMS_SoftDownLists", new[] { "SoftId" });
            DropIndex("dbo.CMS_PhotoLists", "IX_PhotoList");
            DropIndex("dbo.CMS_ShoppingCarts", new[] { "GoodsId" });
            DropIndex("dbo.CMS_Tags", new[] { "TagName" });
            DropIndex("dbo.CMS_Tags", new[] { "ModelId" });
            DropIndex("dbo.CMS_DiggDiaries", new[] { "DiggId" });
            DropIndex("dbo.CMS_Diggs", new[] { "ContentId" });
            DropIndex("dbo.CMS_Comments", new[] { "ContentId" });
            DropIndex("dbo.CMS_Comments", new[] { "ReplyId" });
            DropIndex("dbo.CMS_UserAddresses", new[] { "UserId" });
            DropIndex("dbo.CMS_Businesses", new[] { "UserId" });
            DropIndex("dbo.CMS_Users", new[] { "IsAdmin" });
            DropIndex("dbo.CMS_Users", new[] { "UserName" });
            DropIndex("dbo.CMS_Categories", new[] { "Path" });
            DropIndex("dbo.CMS_Categories", new[] { "ModelId" });
            DropIndex("dbo.CMS_Cores", new[] { "ContentTitle" });
            DropIndex("dbo.CMS_Cores", new[] { "CategoryId" });
            DropIndex("dbo.CMS_Areas", new[] { "DeliveryArea_Id" });
            DropIndex("dbo.CMS_Annexes", new[] { "ContentId" });
            DropTable("dbo.CMS_Softs");
            DropTable("dbo.CMS_Photos");
            DropTable("dbo.CMS_Goods");
            DropTable("dbo.CMS_Articles");
            DropTable("dbo.CMS_CoreTags");
            DropTable("dbo.CMS_CoreSpecials");
            DropTable("dbo.CMS_CoreCategories");
            DropTable("dbo.CMS_CategoryUsers");
            DropTable("dbo.CMS_RightUsers");
            DropTable("dbo.CMS_RightRoles");
            DropTable("dbo.CMS_RoleUsers");
            DropTable("dbo.CMS_RoleCategories");
            DropTable("dbo.CMS_Words");
            DropTable("dbo.CMS_Votes");
            DropTable("dbo.CMS_VoteChoices");
            DropTable("dbo.CMS_UserScores");
            DropTable("dbo.CMS_UserMoneys");
            DropTable("dbo.CMS_Units");
            DropTable("dbo.CMS_UDTs");
            DropTable("dbo.CMS_Templates");
            DropTable("dbo.CMS_Tasks");
            DropTable("dbo.CMS_TaskActives");
            DropTable("dbo.CMS_SecurityCenters");
            DropTable("dbo.CMS_PaymentMethods");
            DropTable("dbo.CMS_OrderLists");
            DropTable("dbo.CMS_Messages");
            DropTable("dbo.CMS_Logs");
            DropTable("dbo.CMS_IPBlackLists");
            DropTable("dbo.CMS_Invoices");
            DropTable("dbo.CMS_HotKeyWords");
            DropTable("dbo.CMS_Helps");
            DropTable("dbo.CMS_GuestBooks");
            DropTable("dbo.CMS_GoodsParts");
            DropTable("dbo.CMS_GoodsImgs");
            DropTable("dbo.CMS_GoodsCustomFieldValues");
            DropTable("dbo.CMS_GoodsCustomFields");
            DropTable("dbo.CMS_GatherUrlCaches");
            DropTable("dbo.CMS_GatherHistories");
            DropTable("dbo.CMS_FriendLinks");
            DropTable("dbo.CMS_Fields");
            DropTable("dbo.CMS_Favorites");
            DropTable("dbo.CMS_ExtensionCategoryLists");
            DropTable("dbo.CMS_ExtensionCategories");
            DropTable("dbo.CMS_DeliveryMethods");
            DropTable("dbo.CMS_DeliveryAreas");
            DropTable("dbo.CMS_Deliveries");
            DropTable("dbo.CMS_CounterDiaries");
            DropTable("dbo.CMS_CounterContents");
            DropTable("dbo.CMS_ContentProperties");
            DropTable("dbo.CMS_ContentKeyWords");
            DropTable("dbo.CMS_Consultants");
            DropTable("dbo.CMS_Banks");
            DropTable("dbo.CMS_PriceChanges");
            DropTable("dbo.CMS_Orders");
            DropTable("dbo.CMS_BankrollLists");
            DropTable("dbo.CMS_Memus");
            DropTable("dbo.CMS_Models");
            DropTable("dbo.CMS_Gathers");
            DropTable("dbo.CMS_SoftLinkErrs");
            DropTable("dbo.CMS_SoftServers");
            DropTable("dbo.CMS_SoftDownLists");
            DropTable("dbo.CMS_PhotoLists");
            DropTable("dbo.CMS_ShoppingCarts");
            DropTable("dbo.CMS_Brands");
            DropTable("dbo.CMS_Tags");
            DropTable("dbo.CMS_Specials");
            DropTable("dbo.CMS_DiggDiaries");
            DropTable("dbo.CMS_Diggs");
            DropTable("dbo.CMS_Comments");
            DropTable("dbo.CMS_UserAddresses");
            DropTable("dbo.CMS_Roles");
            DropTable("dbo.CMS_Rights");
            DropTable("dbo.CMS_Businesses");
            DropTable("dbo.CMS_Users");
            DropTable("dbo.CMS_Categories");
            DropTable("dbo.CMS_Cores");
            DropTable("dbo.CMS_Areas");
            DropTable("dbo.CMS_Announces");
            DropTable("dbo.CMS_Annexes");
            DropTable("dbo.CMS_Adverts");
        }
    }
}
